import {getShopData} from "../../api/business";
export default {
    namespaced: true,
    state:{
        shops:[]
    },
    mutations:{
        //设置商铺列表
        ["SET_SHOPS"](state,payload){
			console.log(payload.shops)
            state.shops=payload.shops;
        },
		//设置商铺分页数据
		["SET_SHOPS_PAGE"](state,payload){
		state.shops.push(...payload.shops)
		}
    },
    actions: {
    		//显示首页商家列表
    		getShop(conText, payload) {
    			getShopData(payload).then(res => {
    				console.log(res)
    				if (res.code == 200) {
    					conText.commit("SET_SHOPS", {
    						shops: res.data
    					});
    					if (payload.success) {
    						payload.success(res.pageinfo.pagenum)
    					}
    				}
    				// 判断完成状态
    				if (payload.complete) {
    					payload.complete()
    				}
    			})
    		},
    		//显示首页分页商家数据
    		getShopPage(context,payload){
    			getShopData(payload).then(res=>{
    				if(res.code==200){
    					context.commit("SET_SHOPS_PAGE",{shops:res.data})
    				}
    				
    			})
    		}
    	}
}